<?php


namespace app\admin\model\Admin;


use think\facade\Db;
use think\Model;

class AdminRoleRelationModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "admin_role_relation";

    /**
     * 获取管理员权限
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getAdminRoleRelationJoinWhere($where)
    {
        array_push($where, ['ar.is_show','=','1']);
        $field = ['ar.role_name', 'ar.menu_ids'];
        $list = Db::name('admin_role_relation')
            ->alias('arr')
            ->join('admin_role ar', 'arr.role_id = ar.id')
            ->field($field)
            ->where($where)
            ->select()->toArray();
        return $list;
    }

    /**
     * 根据条件查询多条
     * @param $where
     * @return array
     * @throws
     */
    public static function getAdminRoleRelationWhereMore($where)
    {
        $list = Db::name('admin_role_relation')->where($where)->select()->toArray();
        return $list;
    }

    /**
     * 批量添加
     * @param $data
     * @return int
     */
    public static function addAdminRoleRelation($data)
    {
        $flag = Db::name("admin_role_relation")->insertAll($data);
        return $flag;
    }

    /**
     * 删除
     * @param $where
     * @return int
     * @throws
     */
    public static function delAdminRoleRelationWhere($where)
    {
        $flag = Db::name('admin_role_relation')->where($where)->delete();
        return $flag;
    }

}